home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 8: LINUX Games / Linux Cubed Series 8 - LINUX Games.iso / games / x11 / strategy / xsok-1.000 / xsok-1 / xsok-1.01 / src / X-sound_SUN.c < prev    next >
C/C++ Source or Header  |  1994-11-24  |  1KB  |  44 lines

  1. /*****************************************************************************/
  2. /*                                         */
  3. /*                                         */
  4. /*    Xsok version 1.00 -- module X-sound_SUN.c                 */
  5. /*                                         */
  6. /*    SUN audio functions play_sound().                     */
  7. /*    Written by Michael Bischoff (mbi@mo.math.nat.tu-bs.de)             */
  8. /*    November-1994                                 */
  9. /*    see COPYRIGHT.xsok for Copyright details                 */
  10. /*                                         */
  11. /*                                         */
  12. /*****************************************************************************/
  13. #ifdef SOUND
  14. #include "X-sok.h"
  15.  
  16. #ifndef AUDIO_DEVICE
  17. #define AUDIO_DEVICE "/dev/audio"
  18. #endif
  19.  
  20. void play_sound(const char *filename) {
  21.     static int audio = 1;
  22.     if (audio && checksound()) {
  23.     char fullname[200];
  24.     FILE *fp, *fsnd;
  25.     int c;
  26.     if (!(fsnd = fopen(AUDIO_DEVICE, "wb"))) {
  27.         audio = 0;
  28.         return;        /* cannot open /dev/audio */
  29.     }
  30.     XSync(dpy, 0);    /* text first! */
  31.     sprintf(fullname, "%s/audio/%s.au", xsokdir, filename);
  32.     if (!(fp = fopen(fullname, "rb"))) {
  33.         fclose(fsnd);
  34.         return;
  35.     }
  36.     /* yeah, copy data */
  37.     while ((c = getc(fp)) != EOF)
  38.         fputc(c, fsnd);
  39.     fclose(fsnd);
  40.     fclose(fp);
  41.     }
  42. }
  43. #endif
  44.